//获取应用实例 
var app = getApp()
Page({
  data: {
    amount: 0,
    amount_current:0,
    amount_last:0,
    todaynum:0,
    todayamount1:0,
    lastdayamount1:0,
    monthamount1:0,
    monthamount2:0,
    amount_last_finish:0,
    amount_last:0
  },
  onShow:function(){
    
  },
  onReady:function(){
    this.getDeviceInfo();
  },
  onLoad: function () {
    this.getTeamList();
  },

  getDeviceInfo: function () {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          deviceW: res.windowWidth,
          deviceH: res.windowHeight
        })
      }
    })
  },


  //获取收益统计
  getTeamList() {
    var that = this;
    wx.request({
      url: app.globalData.api + '/app.php?c=UserBalanceRecord&a=statistics',
      data:
      {
        token: app.globalData.token,
      },
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
        'platform': '' + app.globalData.platform,
        'version': '' + app.globalData.version,
      },
      method: 'POST',
      dataType: 'json',
      success: function (res) {
        console.log(res);
        if (res.data.code == 0) {
          that.setData({
            amount: res.data.data.amount,
            todaynum:res.data.data.today.num,
            todayamount1: res.data.data.today.amount1,
            lastdayamount1: res.data.data.yesterday.amount1,
            monthamount1: res.data.data.lastmonth.amount1,
            monthamount2:res.data.data.lastmonth.amount2,
            amount_last: res.data.data.amount_last,
            amount_last_finish: res.data.data.amount_last_finish
          })
        } else {
          wx.showToast({
            title: '' + res.data.msg,
            icon: 'none',
            duration: 1000
          })
        }

      }, fail: function () {

      }
    });
  },
  
//提现
  cashout(){
    wx.navigateTo({
      url: '/pages/mine/wallet',
    })
  },
  //结算明细
  pay_detail() {
    wx.navigateTo({
      url: '/pages/mine/cash-detail',
    })
  },

  //交易记录
  pay_record(){
    wx.navigateTo({
      url: '/pages/mine/pay-record',
    })
  }
})
